package com.fh.shop.api.util;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class SMSUtil {

    private static final String APPKEY = "46ee39f0c89b39e9e3b66e67772a582b";//46ee39f0c89b39e9e3b66e67772a582b
    private static final String APPSECRET = "18cd344fa39c";//18cd344fa39c
    private static final String URL = "https://api.netease.im/sms/sendcode.action";


    public static String sendMsg(String phone){

        Map<String, String> headerMap = new HashMap<>();
        headerMap.put("AppKey", APPKEY);
        String nonce = UUID.randomUUID().toString();
        headerMap.put("Nonce", nonce);
        String time = new Date().getTime() + "";
        headerMap.put("CurTime", time);
        String sign = CheckSumBuilder.getCheckSum(APPSECRET, nonce, time);
        headerMap.put("CheckSum", sign);

        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("mobile", phone);
//        paramMap.put("templateid", "19509023"); //19509023
        paramMap.put("codeLen", "6");

        String res = HttpClientUtil.sendPost(URL, headerMap, paramMap);
        return res;
    }
}
